function displayTime() {
    var now = new Date();
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var timeString = year + "-" + addLeadingZero(month) + "-" + addLeadingZero(day) + " " + addLeadingZero(hours) + ":" + addLeadingZero(minutes) + ":" + addLeadingZero(seconds);
    var currentTime = document.getElementById("current-time");
    if (currentTime) {
      currentTime.innerHTML = timeString;
    }
  }
  
  function addLeadingZero(number) {
    if (number < 10) {
      return "0" + number;
    } else {
      return number;
    }
  }
  
  displayTime();
  setInterval(displayTime, 1000);